/**
 * 
 */
package com.jjt.kiki.service;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import com.jjt.kiki.bean.Res;
import com.jjt.kiki.dao.ResDao;

/**
 * @author jjtEatJava
 *
 */
public class ResService {
	private ResDao resDao = new ResDao();

	public int save(List<Res> share) {
		Iterator<Res> i = share.iterator();
		while (i.hasNext()) {
			Res res = i.next();
			if (this.isExist(res))
				i.remove();
		}
		resDao.save(share);
		return share.size();
	}

	private boolean isExist(Res res) {
		int count = resDao.findByResShortUrl(res);
		if (count > 0)
			return true;
		return false;
	}
}
